Skip to content

statistics: add docs for the FLUSH STATS_DELTA statement#21819

Open
qiancai wants to merge 2 commits into
pingcap:masterfrom
qiancai:add-flush-stats-delta-doc-23258
Open

statistics: add docs for the FLUSH STATS_DELTA statement#21819
qiancai wants to merge 2 commits into
pingcap:masterfrom
qiancai:add-flush-stats-delta-doc-23258

Conversation

@qiancai

@qiancai qiancai commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

What is changed, added or deleted? (Required)

Add documentation for the FLUSH STATS_DELTA statement introduced in v8.5.7 and v9.0.0 (pingcap/tidb#65668), which persists the pending statistics delta buffered in TiDB memory to the mysql.stats_meta system table immediately.

  • Add a new page: sql-statements/sql-statement-flush-stats-delta.md (synopsis, options, examples, privileges).
  • Add the statement to TOC.md and sql-statements/sql-statement-overview.md.
  • Cross-link the statement from the "Automatic update" section in statistics.md.

All examples and behavior descriptions (target scopes, CLUSTER broadcast, privilege requirements, and warnings) are verified against a TiDB v8.5.7 TiUP playground with two TiDB instances.

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions.

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)

What is the related PR or file link(s)?

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

Summary by CodeRabbit

  • New Features
    • Added documentation for the FLUSH STATS_DELTA statement, including syntax, targets, permissions, examples, and behavior.
    • Added FLUSH STATS_DELTA to the SQL statement reference and statistics management documentation.
  • Documentation
    • Updated release notes to link to the new statement documentation.
    • Documented immediate persistence of pending statistics updates in supported versions.

@qiancai qiancai added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. translation/from-docs This PR is translated from a PR in pingcap/docs. v9.0-beta.3 This PR/issue applies to TiDB v9.0-beta.3. labels Jul 17, 2026
@ti-chi-bot ti-chi-bot Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jul 17, 2026
Synced from: pingcap/docs#23258
Target PR: pingcap#21819
AI Provider: azure

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Auto-sync completed successfully

Source PR: pingcap/docs#23258
Target PR: #21819

Chinese documentation has been updated based on English documentation changes.

@ti-chi-bot

ti-chi-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kissmydb for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds Chinese documentation for FLUSH STATS_DELTA, covering syntax, targets, cluster behavior, examples, permissions, compatibility, and references. Related SQL indexes, statistics guidance, the table of contents, and release notes are updated.

Changes

FLUSH STATS_DELTA documentation

Layer / File(s) Summary
Statement behavior and syntax
sql-statements/sql-statement-flush-stats-delta.md
Documents immediate statistics delta persistence, supported targets, CLUSTER, deduplication, partition handling, and missing-object behavior.
Usage, permissions, and compatibility
sql-statements/sql-statement-flush-stats-delta.md
Adds single-table, wildcard, and cluster examples, required SELECT permissions, MySQL compatibility details, and related references.
Documentation navigation and statistics guidance
sql-statements/sql-statement-overview.md, statistics.md, TOC.md, releases/release-8.5.7.md
Adds the statement to SQL and TOC indexes, explains its availability for statistics persistence, and links it from the release notes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: lilin90

Poem

A rabbit hops through stats at night,
Flushing deltas into light.
Syntax blooms and links align,
Cluster carrots queue in line.
Docs now guide each data trail—
Hop, hop, flush, and details sail!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main documentation addition for FLUSH STATS_DELTA.
Description check ✅ Passed The description covers the change, affected versions, related links, and scope, with only an optional checklist section omitted.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@sql-statements/sql-statement-flush-stats-delta.md`:
- Line 10: Correct the shared automatic-update links: in
sql-statements/sql-statement-flush-stats-delta.md lines 10-10, change the label
from 自动修改 to 自动更新 and target /statistics.md#自动更新; in statistics.md lines 19-19,
update the self-reference target to /statistics.md#自动更新.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e78484c2-a88f-4f97-be6c-40836ad12543

📥 Commits

Reviewing files that changed from the base of the PR and between bae0ddc and a98cd8f.

📒 Files selected for processing (5)
  • TOC.md
  • releases/release-8.5.7.md
  • sql-statements/sql-statement-flush-stats-delta.md
  • sql-statements/sql-statement-overview.md
  • statistics.md


`FLUSH STATS_DELTA` 会立即将 TiDB 内存中缓冲的待持久化统计信息 delta 持久化到 [`mysql.stats_meta`](/mysql-schema/mysql-schema.md#statistics-system-tables) 系统表中。

当你使用 DML 语句(例如 `INSERT`、`UPDATE` 和 `DELETE`)修改数据时,TiDB 会记录每个受影响表的总行数和已修改行数的变化,将这些变化(称为 statistics delta)缓存在执行这些语句的 TiDB 节点内存中,并每隔 20 * [`stats-lease`](/tidb-configuration-file.md#stats-lease)(默认 60 秒)将其持久化到 `mysql.stats_meta` 系统表中。更多信息,参见[自动修改](/statistics.md#automatic-update)。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the shared automatic-update anchor.

Both links target #automatic-update, while the supplied Chinese heading is ### 自动更新; the new statement page also uses the inaccurate label 自动修改.

  • sql-statements/sql-statement-flush-stats-delta.md#L10-L10: change the label to 自动更新 and target /statistics.md#自动更新.
  • statistics.md#L19-L19: change the self-reference target to /statistics.md#自动更新.
📍 Affects 2 files
  • sql-statements/sql-statement-flush-stats-delta.md#L10-L10 (this comment)
  • statistics.md#L19-L19
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sql-statements/sql-statement-flush-stats-delta.md` at line 10, Correct the
shared automatic-update links: in
sql-statements/sql-statement-flush-stats-delta.md lines 10-10, change the label
from 自动修改 to 自动更新 and target /statistics.md#自动更新; in statistics.md lines 19-19,
update the self-reference target to /statistics.md#自动更新.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. translation/from-docs This PR is translated from a PR in pingcap/docs. v9.0-beta.3 This PR/issue applies to TiDB v9.0-beta.3.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant